import request from "@/utils/request";

// 为员工分配角色
export function assignRoles(data) {
  return request({
    url: "/api/system/ae/employee-roles/assign",
    method: "post",
    data,
  });
}

// 添加员工角色关系
export function addEmployeeRole(data) {
  return request({
    url: "/api/system/ae/employee-roles",
    method: "post",
    data,
  });
}

// 删除员工角色关系（根据关系ID）
export function deleteEmployeeRole(id) {
  return request({
    url: `/api/system/ae/employee-roles/${id}`,
    method: "delete",
  });
}

// 根据员工ID和角色ID删除关系
export function deleteEmployeeRoleByIds(employeeId, roleId) {
  return request({
    url: "/api/system/ae/employee-roles/by-ids",
    method: "delete",
    params: {
      employeeId,
      roleId,
    },
  });
}

// 删除员工的所有角色
export function deleteByEmployeeId(employeeId) {
  return request({
    url: `/api/system/ae/employee-roles/by-employee/${employeeId}`,
    method: "delete",
  });
}

// 删除角色的所有员工
export function deleteByRoleId(roleId) {
  return request({
    url: `/api/system/ae/employee-roles/by-role/${roleId}`,
    method: "delete",
  });
}

// 获取员工的角色列表
export function getByEmployeeId(employeeId) {
  return request({
    url: `/api/system/ae/employee-roles/by-employee/${employeeId}`,
    method: "get",
  });
}

// 获取角色的员工列表
export function getByRoleId(roleId) {
  return request({
    url: `/api/system/ae/employee-roles/by-role/${roleId}`,
    method: "get",
  });
}

// 分页查询员工角色关系
export function getEmployeeRoleList(params) {
  return request({
    url: "/api/system/ae/employee-roles",
    method: "get",
    params,
  });
}
